package junit.skeleton.server.user;

import static org.junit.Assert.*;

import java.util.Random;

import javax.annotation.Resource;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.skeleton.common.base.dto.ResultDto;
import com.skeleton.db.dto.UserinfoDto;
import com.skeleton.server.user.service.IUserService;
import com.skeleton.utils.SystemConstants;
import com.skeleton.utils.SystemTools;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/WEB-INF/config/applicationContext.xml"})
public class UserTest {

	protected Logger logger = LogManager.getLogger(this.getClass());
	
	@Resource
	private IUserService iUserService;

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testAjaxLogin() {
		UserinfoDto ud = new UserinfoDto();
		ud.setUserLoginname("test"+new Random().nextInt(100000));
		ud.setUserPassword("test");
		ud.setUserNickname("test");
		ud.setUserRegistDttm(SystemTools.convertCurrentDTTMtoInt());
		ud.setUserRegistIp("127.0.0.1");
		ud.setUserStatus(SystemConstants.USER_STATUS_NORMAL);
		ud.setUserLevel(SystemConstants.USER_LEVEL_NORMAL);
		
		ResultDto<UserinfoDto> rd = iUserService.doSimpleRegist(ud);
		if (rd.isSuccess()) {
			logger.info("============11===");
		} else {
			fail("Not yet implemented");
		}
	}


}
